use diesel::{pg::PgConnection, result::Error};


pub trait CRUD<CreatedModel, UpdateModel, PK> {
    fn create(conn: &PgConnection, from: &CreatedModel) -> Result<Self, Error>
        where
            Self: Sized;

    fn read(conn: &PgConnection,  page: i64, page_size: i64) -> Vec<Self>
        where
            Self: Sized;

    fn update(conn: &PgConnection, pk: PK, value: &UpdateModel) -> Result<Self, Error>
        where
            Self: Sized;

    fn delete(conn: &PgConnection, pk: PK) -> Result<usize, Error>
        where
            Self: Sized;

    fn get_by_pk(conn: &PgConnection, pk: PK) -> Result<Self, Error>
        where
            Self: Sized;
}


pub mod code;
pub mod course_type;
pub mod course;
pub mod resource;
pub mod school_course;
pub mod school;
pub mod user_info;
pub mod user;
